Is `std::string(strerror(errno))` dangerous?
Posted
by StackedCrooked
on Stack Overflow
See other posts from Stack Overflow
or by StackedCrooked
Published on 2010-06-08T08:24:11Z
Indexed on
2010/06/08
8:32 UTC
Read the original article
Hit count: 137
At some places in my code, I print debug messages like this:
int ret = getLinkSpeed(device.getSysName(), linkSpeed);
if (ret < 0)
{
logDebug("Failed to obtain port speed for this device. Error: " + std::string(strerror(errno)));
}
From the documentation it is not entirely clear if strerror will return 0 under certain conditions (which would cause my code to crash). Does anyone know if it's safe?
© Stack Overflow or respective owner